﻿namespace ACCOUNTING.LVY.Business
{
    using ACCOUNTING;
    using Microsoft.VisualBasic;
    using Microsoft.VisualBasic.CompilerServices;
    using System;
    using System.Data;
    using System.Runtime.CompilerServices;
    using System.Runtime.InteropServices;
    using System.Windows.Forms;

    public class clsDMDoiTuong
    {
        private int mActive = 0;
        private string mDiaChi = "";
        private string mDiaChiGiaoHang = "";
        private string mDienThoai = "";
        private string mDienThoaiDiDong = "";
        private string mEmail = "";
        private string mFax = "";
        private string mGhiChu = "";
        private double mGioiHanNo = 0.0;
        private int mHanThanhToan = 0;
        private byte[] mHinhDongDau;
        private string mKhoa = "";
        private string mKhoaKhuVuc = "";
        private string mKhoaLoaiGia = "";
        private string mKhoaLoaiKhachHang = "";
        private string mKhoaNganh = "";
        private string mKhoaNhanVienCapNhat = "";
        private string mKhoaNhanVienQuanLy = "";
        private string mKhoaQuocGia = "";
        private string mKhoaTinhThanh = "";
        private string mLoai = "";
        private string mMa = "";
        private string mMaSoThue = "";
        private int mSend = 0;
        private string mTenAnh = "";
        private string mTenViet = "";
        private string mTuNgay = "";
        private string mWebsite = "";

        public bool DelData(string pKhoa)
        {
            bool flag=false;
            string commandText = "";
            try
            {
                commandText = "DELETE FROM DM_LienHeDoiTuong WHERE KhoaDoiTuong = '" + pKhoa.Trim() + "'";
                DBHelper.ExecuteNonQuery(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]);
                commandText = "DELETE FROM DM_DiaChiGiaoHang WHERE KhoaDoiTuong = '" + pKhoa.Trim() + "'";
                DBHelper.ExecuteNonQuery(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]);
                commandText = "DELETE FROM DM_DoiTuong WHERE Khoa = '" + pKhoa.Trim() + "'";
                bool flag2 = DBHelper.ExecuteNonQuery(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]) > 0;
                flag = flag2;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                flag = false;
                ProjectData.ClearProjectError();
                return flag;
                ProjectData.ClearProjectError();
            }
            return flag;
        }

        public bool DelDiaChiGiaoHang(string pKhoa)
        {
            bool flag=false;
            string commandText = "";
            try
            {
                commandText = "DELETE FROM DM_DiaChiGiaoHang WHERE Khoa = '" + pKhoa.Trim() + "'";
                bool flag2 = DBHelper.ExecuteNonQuery(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]) > 0;
                flag = flag2;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                flag = false;
                ProjectData.ClearProjectError();
                return flag;
                ProjectData.ClearProjectError();
            }
            return flag;
        }

        public DataTable GetContactor(string pKhoa)
        {
            DataTable table;
            try
            {
                string commandText = "SELECT Khoa, Ten, ChucDanh, DienThoai, Email, DiaChi, TruongDaiDien FROM DM_LienHeDoiTuong  WHERE KhoaDoiTuong = '" + pKhoa + "'";
                table = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]).Tables[0];
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message);
                table = null;
                ProjectData.ClearProjectError();
                return table;
                ProjectData.ClearProjectError();
            }
            return table;
        }

        public DataTable GetDataHinhDongDau(string strKhoa)
        {
            string commandText = "SELECT * FROM HT_KyTenDongDau WHERE KhoaNhanVien = '" + strKhoa + "'";
            return DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]).Tables[0];
        }

        public DataTable GetDataPrint(string strConditions = "")
        {
            DataTable table;
            string str2 = "";
            try
            {
                if (strConditions.Trim() != "")
                {
                    str2 = strConditions;
                }
                string commandText = " SELECT LKH.Ten" + modGeneral.H_LANGUAGE + " As LoaiKhachHang, KV.Ten" + modGeneral.H_LANGUAGE + " As KhuVuc, HH.Ten" + modGeneral.H_LANGUAGE + " as Nganh,  DT.Ten" + modGeneral.H_LANGUAGE + " as Ten, DT.Ma, DT.DiaChi, DT.DienThoai, DT.Fax, DT.Email,  DT.MaSoThue, LH.Ten as DaiDien  FROM DM_DoiTuong DT  LEFT JOIN DM_LienHeDoiTuong LH on DT.Khoa = LH.KhoaDoiTuong and LH.TruongDaiDien = 1  LEFT JOIN DM_LoaiKhachHang LKH on DT.KhoaLoaiKhachHang = LKH.Khoa  LEFT JOIN DM_KhuVuc KV on DT.KhoaKhuVuc = KV.Khoa  LEFT JOIN DM_NganhKinhDoanh HH on DT.KhoaNganh = HH.Khoa  WHERE DT.Active = 1 " + str2;
                table = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]).Tables[0];
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message);
                table = null;
                ProjectData.ClearProjectError();
                return table;
                ProjectData.ClearProjectError();
            }
            return table;
        }

        public DataTable GetListDiaChiGiaoHang(string strKhoaDoiTuong)
        {
            DataTable table;
            string commandText = "";
            try
            {
                commandText = " SELECT '0000000000' as Khoa, DiaChiGiaoHang FROM DM_DoiTuong Where Khoa = '" + strKhoaDoiTuong + "'";
                DataTable table3 = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]).Tables[0];
                commandText = " SELECT Khoa, Rtrim(DiaChiGiaoHang) as DiaChiGiaoHang FROM DM_DiaChiGiaoHang Where KhoaDoiTuong = '" + strKhoaDoiTuong + "' ORDER BY Khoa";
                DataTable table2 = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]).Tables[0];
                if (this.mDiaChiGiaoHang.Trim() != "")
                {
                    DataRow row = table2.NewRow();
                    row[0] = RuntimeHelpers.GetObjectValue(table3.Rows[0]["Khoa"]);
                    row[1] = RuntimeHelpers.GetObjectValue(table3.Rows[0]["DiaChiGiaoHang"]);
                    table2.Rows.InsertAt(row, 0);
                }
                table = table2;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                table = null;
                ProjectData.ClearProjectError();
                return table;
                ProjectData.ClearProjectError();
            }
            return table;
        }

        public double GetSoDuCongNo(string KhoaDoiTuong, string NamThang, string Ve, string KhoaDonVi, string SoTaiKhoan)
        {
            double num2;
            string commandText = " SELECT dbo.SoDuCongNo('" + KhoaDoiTuong.Trim() + "','" + NamThang.Trim() + "','" + Ve.Trim() + "','" + KhoaDonVi + "','" + SoTaiKhoan + "')  As SoDuNo ";
            IDataReader dataReader = DBHelper.ExecuteReader(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]);
            if (dataReader.Read())
            {
                num2 = Conversions.ToDouble(modGeneral.GetValue(dataReader, 0, modGeneral.typeOfColumn.GetDecimal));
            }
            else
            {
                num2 = 0.0;
            }
            return Convert.ToDouble(RuntimeHelpers.GetObjectValue(LVYModule.ReturnIfNull(num2, 0, modGeneral.TypeOfValue.Nothing)));
        }

        public bool Load(string pKhoa)
        {
            bool flag=false;
            try
            {
                string commandText = "SELECT * FROM DM_DoiTuong WHERE Khoa = '" + pKhoa + "'";
                IDataReader dataReader = DBHelper.ExecuteReader(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]);
                if (dataReader.Read())
                {
                    this.mKhoa = Conversions.ToString(modGeneral.GetValue(dataReader, 0, modGeneral.typeOfColumn.GetString));
                    this.mMa = Conversions.ToString(modGeneral.GetValue(dataReader, 1, modGeneral.typeOfColumn.GetString));
                    this.mKhoaQuocGia = Conversions.ToString(modGeneral.GetValue(dataReader, 2, modGeneral.typeOfColumn.GetString));
                    this.mKhoaTinhThanh = Conversions.ToString(modGeneral.GetValue(dataReader, 3, modGeneral.typeOfColumn.GetString));
                    this.mKhoaNganh = Conversions.ToString(modGeneral.GetValue(dataReader, 4, modGeneral.typeOfColumn.GetString));
                    this.mKhoaKhuVuc = Conversions.ToString(modGeneral.GetValue(dataReader, 5, modGeneral.typeOfColumn.GetString));
                    this.mTenViet = Conversions.ToString(modGeneral.GetValue(dataReader, 6, modGeneral.typeOfColumn.GetString));
                    this.mTenAnh = Conversions.ToString(modGeneral.GetValue(dataReader, 7, modGeneral.typeOfColumn.GetString));
                    this.mDiaChi = Conversions.ToString(modGeneral.GetValue(dataReader, 8, modGeneral.typeOfColumn.GetString));
                    this.mDiaChiGiaoHang = Conversions.ToString(modGeneral.GetValue(dataReader, 9, modGeneral.typeOfColumn.GetString));
                    this.mDienThoai = Conversions.ToString(modGeneral.GetValue(dataReader, 10, modGeneral.typeOfColumn.GetString));
                    this.mFax = Conversions.ToString(modGeneral.GetValue(dataReader, 11, modGeneral.typeOfColumn.GetString));
                    this.mEmail = Conversions.ToString(modGeneral.GetValue(dataReader, 12, modGeneral.typeOfColumn.GetString));
                    this.mWebsite = Conversions.ToString(modGeneral.GetValue(dataReader, 13, modGeneral.typeOfColumn.GetString));
                    this.mMaSoThue = Conversions.ToString(modGeneral.GetValue(dataReader, 14, modGeneral.typeOfColumn.GetString));
                    this.mLoai = Conversions.ToString(modGeneral.GetValue(dataReader, 15, modGeneral.typeOfColumn.GetString));
                    this.mGhiChu = Conversions.ToString(modGeneral.GetValue(dataReader, 0x10, modGeneral.typeOfColumn.GetString));
                    this.mHanThanhToan = Conversions.ToInteger(modGeneral.GetValue(dataReader, 0x11, modGeneral.typeOfColumn.GetInt32));
                    this.mGioiHanNo = Conversions.ToDouble(modGeneral.GetValue(dataReader, 0x12, modGeneral.typeOfColumn.GetDecimal));
                    this.mKhoaLoaiKhachHang = Conversions.ToString(modGeneral.GetValue(dataReader, 0x13, modGeneral.typeOfColumn.GetString));
                    this.mKhoaNhanVienQuanLy = Conversions.ToString(modGeneral.GetValue(dataReader, 20, modGeneral.typeOfColumn.GetString));
                    this.mKhoaLoaiGia = Conversions.ToString(modGeneral.GetValue(dataReader, 0x15, modGeneral.typeOfColumn.GetString));
                    this.mTuNgay = Conversions.ToString(modGeneral.GetValue(dataReader, 0x16, modGeneral.typeOfColumn.GetString));
                    this.mKhoaNhanVienCapNhat = Conversions.ToString(modGeneral.GetValue(dataReader, 0x17, modGeneral.typeOfColumn.GetString));
                    this.mActive = Conversions.ToInteger(modGeneral.GetValue(dataReader, 0x18, modGeneral.typeOfColumn.GetInt32));
                    this.mSend = Conversions.ToInteger(modGeneral.GetValue(dataReader, 0x19, modGeneral.typeOfColumn.GetInt32));
                }
                dataReader.Close();
                flag = true;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                flag = false;
                ProjectData.ClearProjectError();
                return flag;
                ProjectData.ClearProjectError();
            }
            return flag;
        }

        public void LoadHinhDongDau(string strKhoa)
        {
            string commandText = "SELECT HinhDongDau FROM HT_KyTenDongDau WHERE KhoaNhanVien = '" + strKhoa + "'";
            this.mHinhDongDau = (byte[]) LVYModule.ReturnIfNull(RuntimeHelpers.GetObjectValue(DBHelper.ExecuteScalar(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0])), null, modGeneral.TypeOfValue.Nothing);
        }

        public bool Save(string pTask = "")
        {
            bool flag2;
            IDataParameter[] commandParameters = new IDataParameter[0x1a];
            try
            {
                commandParameters[0] = DBHelper.createParameter("@Khoa", DbType.Int64, ParameterDirection.Input, this.mKhoa);
                commandParameters[1] = DBHelper.createParameter("@Ma", DbType.Int64, ParameterDirection.Input, this.mMa);
                commandParameters[2] = DBHelper.createParameter("@KhoaQuocGia", DbType.Int64, ParameterDirection.Input, this.mKhoaQuocGia);
                commandParameters[3] = DBHelper.createParameter("@KhoaTinhThanh", DbType.Int64, ParameterDirection.Input, this.mKhoaTinhThanh);
                commandParameters[4] = DBHelper.createParameter("@KhoaNganh", DbType.Int64, ParameterDirection.Input, this.mKhoaNganh);
                commandParameters[5] = DBHelper.createParameter("@KhoaKhuVuc", DbType.Int64, ParameterDirection.Input, this.mKhoaKhuVuc);
                commandParameters[6] = DBHelper.createParameter("@TenViet", DbType.Int64, ParameterDirection.Input, this.mTenViet);
                commandParameters[7] = DBHelper.createParameter("@TenAnh", DbType.Int64, ParameterDirection.Input, this.mTenAnh);
                commandParameters[8] = DBHelper.createParameter("@DiaChi", DbType.Int64, ParameterDirection.Input, this.mDiaChi);
                commandParameters[9] = DBHelper.createParameter("@DiaChiGiaoHang", DbType.Int64, ParameterDirection.Input, this.mDiaChiGiaoHang);
                commandParameters[10] = DBHelper.createParameter("@DienThoai", DbType.Int64, ParameterDirection.Input, this.mDienThoai);
                commandParameters[11] = DBHelper.createParameter("@Fax", DbType.Int64, ParameterDirection.Input, this.mFax);
                commandParameters[12] = DBHelper.createParameter("@Email", DbType.Int64, ParameterDirection.Input, this.mEmail);
                commandParameters[13] = DBHelper.createParameter("@Website", DbType.Int64, ParameterDirection.Input, this.mWebsite);
                commandParameters[14] = DBHelper.createParameter("@MaSoThue", DbType.Int64, ParameterDirection.Input, this.mMaSoThue);
                commandParameters[15] = DBHelper.createParameter("@Loai", DbType.Int64, ParameterDirection.Input, this.mLoai);
                commandParameters[0x10] = DBHelper.createParameter("@GhiChu", DbType.Int64, ParameterDirection.Input, this.mGhiChu);
                commandParameters[0x11] = DBHelper.createParameter("@HanThanhToan", DbType.Double, ParameterDirection.Input, this.mHanThanhToan);
                commandParameters[0x12] = DBHelper.createParameter("@GioiHanNo", DbType.Date, ParameterDirection.Input, this.mGioiHanNo);
                commandParameters[0x13] = DBHelper.createParameter("@KhoaLoaiKhachHang", DbType.Int64, ParameterDirection.Input, this.mKhoaLoaiKhachHang);
                commandParameters[20] = DBHelper.createParameter("@KhoaNhanVienQuanLy", DbType.Int64, ParameterDirection.Input, this.mKhoaNhanVienQuanLy);
                commandParameters[0x15] = DBHelper.createParameter("@KhoaLoaiGia", DbType.Int64, ParameterDirection.Input, this.mKhoaLoaiGia);
                commandParameters[0x16] = DBHelper.createParameter("@TuNgay", DbType.Int64, ParameterDirection.Input, this.mTuNgay);
                commandParameters[0x17] = DBHelper.createParameter("@KhoaNhanVienCapNhat", DbType.Int64, ParameterDirection.Input, this.mKhoaNhanVienCapNhat);
                commandParameters[0x18] = DBHelper.createParameter("@Active", DbType.Double, ParameterDirection.Input, this.mActive);
                commandParameters[0x19] = DBHelper.createParameter("@Send", DbType.Double, ParameterDirection.Input, this.mSend);
                bool flag = DBHelper.ExecuteNonQuery(modGeneral.ConnectionString, CommandType.StoredProcedure, "sp_DM_DoiTuong", commandParameters) > 0;
                flag2 = true;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                flag2 = false;
                ProjectData.ClearProjectError();
                return flag2;
                ProjectData.ClearProjectError();
            }
            return flag2;
        }

        public bool SaveDiaChiGiaoHang(string strKhoa, string strKhoaDoiTuong, string strDiaChiGiaoHang)
        {
            bool flag2;
            IDataParameter[] commandParameters = new IDataParameter[3];
            try
            {
                commandParameters[0] = DBHelper.createParameter("@Khoa", DbType.Int64, ParameterDirection.Input, strKhoa);
                commandParameters[1] = DBHelper.createParameter("@KhoaDoiTuong", DbType.Int64, ParameterDirection.Input, strKhoaDoiTuong);
                commandParameters[2] = DBHelper.createParameter("@DiaChiGiaoHang", DbType.Int64, ParameterDirection.Input, strDiaChiGiaoHang);
                bool flag = DBHelper.ExecuteNonQuery(modGeneral.ConnectionString, CommandType.StoredProcedure, "sp_DM_DiaChiGiaoHang", commandParameters) > 0;
                flag2 = true;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                flag2 = false;
                ProjectData.ClearProjectError();
                return flag2;
                ProjectData.ClearProjectError();
            }
            return flag2;
        }

        public bool SaveHinhDongDau()
        {
            bool flag2;
            IDataParameter[] commandParameters = new IDataParameter[2];
            try
            {
                commandParameters[0] = DBHelper.createParameter("@Khoa", DbType.Int64, ParameterDirection.Input, this.mKhoa);
                commandParameters[1] = DBHelper.createParameter("@HinhDongDau", DbType.Decimal, ParameterDirection.Input, this.mHinhDongDau);
                bool flag = DBHelper.ExecuteNonQuery(modGeneral.ConnectionString, CommandType.StoredProcedure, "HT_sp_KyTenDongDau", commandParameters) > 0;
                flag2 = true;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                flag2 = false;
                ProjectData.ClearProjectError();
                return flag2;
                ProjectData.ClearProjectError();
            }
            return flag2;
        }

        public string SearchByCode(string strCode = "", string strLoaiDoiTuong = "")
        {
            string str4;
            string commandText = "";
            IDataParameter parameter = null;
            string str3 = "";
            string str = "";
            try
            {
                if (strCode.Trim() != "")
                {
                    str3 = " AND RTRIM(Ma) = '" + strCode.Trim() + "'";
                }
                if (strLoaiDoiTuong.Trim() != "")
                {
                    str3 = str3 + " AND CharIndex('" + strLoaiDoiTuong + "',Loai) <> 0 ";
                }
                commandText = "SELECT Khoa, Ma, Ten" + modGeneral.H_LANGUAGE + " as Ten  FROM DM_DoiTuong WHERE Active = 1 " + str3;
                IDataReader dataReader = DBHelper.ExecuteReader(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[] { parameter });
                if (dataReader.Read())
                {
                    str = modGeneral.GetValue(dataReader, 0, modGeneral.typeOfColumn.GetString).ToString() + "|" + modGeneral.GetValue(dataReader, 1, modGeneral.typeOfColumn.GetString).ToString() + "|" + modGeneral.GetValue(dataReader, 2, modGeneral.typeOfColumn.GetString).ToString();
                }
                dataReader.Close();
                str4 = str;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                str4 = "";
                ProjectData.ClearProjectError();
                return str4;
                ProjectData.ClearProjectError();
            }
            return str4;
        }

        public void SetChiNhanh(int pTask, string strKhoa)
        {
            string str;
            if (pTask == 0)
            {
                str = " UPDATE DM_DoiTuong Set Loai = Replace(Loai, 'U', '') WHERE Khoa = '" + strKhoa + "'";
            }
            else
            {
                str = " UPDATE DM_DoiTuong Set Loai = Rtrim(Loai) + 'U' WHERE Khoa = '" + strKhoa + "'";
            }
            DBHelper.ExecuteNonQuery(modGeneral.ConnectionString, CommandType.Text, str, new IDataParameter[0]);
        }

        public DataTable ShowAllList(string strLoaiDoiTuong = "")
        {
            DataTable table;
            string commandText = "";
            string str2 = "";
            try
            {
                if (strLoaiDoiTuong.Trim() != "")
                {
                    str2 = " WHERE CharIndex('" + strLoaiDoiTuong.Trim() + "', Loai) <> 0 ";
                }
                commandText = " SELECT Khoa, Rtrim(Ma) as Ma, Rtrim(Ten" + modGeneral.H_LANGUAGE + ") as Ten  FROM DM_DoiTuong " + str2 + " ORDER BY Ma ";
                table = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]).Tables[0];
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                table = null;
                ProjectData.ClearProjectError();
                return table;
                ProjectData.ClearProjectError();
            }
            return table;
        }

        public DataTable ShowList(string strLoaiDoiTuong = "", string strConditions = "")
        {
            DataTable table;
            string commandText = "";
            IDataParameter parameter = null;
            string str3 = "";
            try
            {
                if (strLoaiDoiTuong.Trim() != "")
                {
                    str3 = " AND CharIndex('" + strLoaiDoiTuong + "',Loai) <> 0 ";
                }
                if (strConditions.Trim() != "")
                {
                    str3 = str3 + " AND " + strConditions;
                }
                commandText = " SELECT Khoa, Rtrim(Ma) as Ma, Rtrim(Ten" + modGeneral.H_LANGUAGE + ") as Ten, DiaChi, MaSoThue, DienThoai  FROM DM_DoiTuong WHERE Active = 1 " + str3 + " ORDER BY 3 ";
                table = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[] { parameter }).Tables[0];
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                table = null;
                ProjectData.ClearProjectError();
                return table;
                ProjectData.ClearProjectError();
            }
            return table;
        }

        public DataTable ShowListByField(string strFieldList, string strConditions = "", string strOrder = "")
        {
            DataTable table;
            string commandText = "";
            IDataParameter parameter = null;
            string str3 = "";
            string str = "";
            strFieldList = Strings.Replace(strFieldList, "|", ",", 1, -1, CompareMethod.Binary);
            try
            {
                if (strConditions.Trim() != "")
                {
                    str3 = " WHERE " + strConditions;
                }
                if (strOrder.Trim() != "")
                {
                    str = " ORDER BY " + strOrder;
                }
                commandText = " SELECT " + strFieldList + "  FROM DM_DoiTuong" + str3 + str;
                table = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[] { parameter }).Tables[0];
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                table = null;
                ProjectData.ClearProjectError();
                return table;
                ProjectData.ClearProjectError();
            }
            return table;
        }

        public string Ten()
        {
            if (modGeneral.H_LANGUAGE.Trim().ToUpper() == "VIET")
            {
                return this.mTenViet;
            }
            return this.mTenAnh;
        }

        public bool TrungMa(string pMa, string pKhoa)
        {
            bool flag2;
            string commandText = "";
            IDataParameter parameter = null;
            try
            {
                commandText = "SELECT * FROM DM_DoiTuong WHERE RTRIM(Ma) = '" + pMa.Trim() + "' AND RTRIM(Khoa) <> '" + pKhoa.Trim() + "'";
                bool flag = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[] { parameter }).Tables[0].Rows.Count > 0;
                flag2 = flag;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message);
                flag2 = true;
                ProjectData.ClearProjectError();
                return flag2;
                ProjectData.ClearProjectError();
            }
            return flag2;
        }

        public bool WasUsed(string pKhoa)
        {
            bool flag2;
            string commandText = "";
            IDataParameter parameter = null;
            try
            {
                commandText = "SELECT top 1 * FROM ST_NhapKho WHERE RTRIM(KhoaDoiTuong) = '" + pKhoa.Trim() + "'";
                bool flag = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[] { parameter }).Tables[0].Rows.Count > 0;
                if (flag)
                {
                    return true;
                }
                commandText = "SELECT top 1 * FROM ST_XuatKho WHERE RTRIM(KhoaDoiTuong) = '" + pKhoa.Trim() + "'";
                flag = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[] { parameter }).Tables[0].Rows.Count > 0;
                flag2 = flag;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message);
                flag2 = true;
                ProjectData.ClearProjectError();
                return flag2;
                ProjectData.ClearProjectError();
            }
            return flag2;
        }

        public int Active
        {
            get
            {
                return this.mActive;
            }
            set
            {
                this.mActive = value;
            }
        }

        public string DiaChi
        {
            get
            {
                return this.mDiaChi;
            }
            set
            {
                this.mDiaChi = value;
            }
        }

        public string DiaChiGiaoHang
        {
            get
            {
                return this.mDiaChiGiaoHang;
            }
            set
            {
                this.mDiaChiGiaoHang = value;
            }
        }

        public string DienThoai
        {
            get
            {
                return this.mDienThoai;
            }
            set
            {
                this.mDienThoai = value;
            }
        }

        public string DienThoaiDiDong
        {
            get
            {
                return this.mDienThoaiDiDong;
            }
            set
            {
                this.mDienThoaiDiDong = value;
            }
        }

        public string Email
        {
            get
            {
                return this.mEmail;
            }
            set
            {
                this.mEmail = value;
            }
        }

        public string Fax
        {
            get
            {
                return this.mFax;
            }
            set
            {
                this.mFax = value;
            }
        }

        public string GhiChu
        {
            get
            {
                return this.mGhiChu;
            }
            set
            {
                this.mGhiChu = value;
            }
        }

        public double GioiHanNo
        {
            get
            {
                return this.mGioiHanNo;
            }
            set
            {
                this.mGioiHanNo = value;
            }
        }

        public int HanThanhToan
        {
            get
            {
                return this.mHanThanhToan;
            }
            set
            {
                this.mHanThanhToan = value;
            }
        }

        public byte[] HinhDongDau
        {
            get
            {
                return this.mHinhDongDau;
            }
            set
            {
                this.mHinhDongDau = value;
            }
        }

        public string Khoa
        {
            get
            {
                return this.mKhoa;
            }
            set
            {
                this.mKhoa = value;
            }
        }

        public string KhoaKhuVuc
        {
            get
            {
                return this.mKhoaKhuVuc;
            }
            set
            {
                this.mKhoaKhuVuc = value;
            }
        }

        public string KhoaLoaiGia
        {
            get
            {
                return this.mKhoaLoaiGia;
            }
            set
            {
                this.mKhoaLoaiGia = value;
            }
        }

        public string KhoaLoaiKhachHang
        {
            get
            {
                return this.mKhoaLoaiKhachHang;
            }
            set
            {
                this.mKhoaLoaiKhachHang = value;
            }
        }

        public string KhoaNganh
        {
            get
            {
                return this.mKhoaNganh;
            }
            set
            {
                this.mKhoaNganh = value;
            }
        }

        public string KhoaNhanVienCapNhat
        {
            get
            {
                return this.mKhoaNhanVienCapNhat;
            }
            set
            {
                this.mKhoaNhanVienCapNhat = value;
            }
        }

        public string KhoaNhanVienQuanLy
        {
            get
            {
                return this.mKhoaNhanVienQuanLy;
            }
            set
            {
                this.mKhoaNhanVienQuanLy = value;
            }
        }

        public string KhoaQuocGia
        {
            get
            {
                return this.mKhoaQuocGia;
            }
            set
            {
                this.mKhoaQuocGia = value;
            }
        }

        public string KhoaTinhThanh
        {
            get
            {
                return this.mKhoaTinhThanh;
            }
            set
            {
                this.mKhoaTinhThanh = value;
            }
        }

        public string Loai
        {
            get
            {
                return this.mLoai;
            }
            set
            {
                this.mLoai = value;
            }
        }

        public string Ma
        {
            get
            {
                return this.mMa;
            }
            set
            {
                this.mMa = value;
            }
        }

        public string MaSoThue
        {
            get
            {
                return this.mMaSoThue;
            }
            set
            {
                this.mMaSoThue = value;
            }
        }

        public int Send
        {
            get
            {
                return this.mSend;
            }
            set
            {
                this.mSend = value;
            }
        }

        public string TenAnh
        {
            get
            {
                return this.mTenAnh;
            }
            set
            {
                this.mTenAnh = value;
            }
        }

        public string TenViet
        {
            get
            {
                return this.mTenViet;
            }
            set
            {
                this.mTenViet = value;
            }
        }

        public string TuNgay
        {
            get
            {
                return this.mTuNgay;
            }
            set
            {
                this.mTuNgay = value;
            }
        }

        public string Website
        {
            get
            {
                return this.mWebsite;
            }
            set
            {
                this.mWebsite = value;
            }
        }
    }
}

